package com.zy.controller;

import com.zy.common.ApiResult;
import com.zy.entity.dto.RegisterUserDTO;
import com.zy.entity.pojo.User;
import com.zy.service.IUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author CarreyZhou
 * @Date: 2024/5/3 11:23
 */
@RestController
@RequestMapping("/login")
@RequiredArgsConstructor
public class LoginController {

    private final IUserService userService;

    @RequestMapping("/test")
    public ApiResult<User> test(@RequestParam("id") Integer id) {
        return ApiResult.success(userService.getUserById(id));
    }

    @PutMapping("/registerUser")
    public ApiResult<String> registerUser(@RequestBody @Validated RegisterUserDTO registerUserDTO) {
        return ApiResult.success(userService.registerUser(registerUserDTO));
    }


}
